package main

import (
	"deployment/core"
	"fmt"
	"log"
	"net/http"

	"golang.org/x/net/websocket"
)

func main() {
	http.HandleFunc("/cmdlist", core.CmdList)
	http.Handle("/deploy", websocket.Handler(core.Deploy))
	http.Handle("/", http.FileServer(http.Dir(core.GetRunPath()+"/dist")))

	port := "1234"

	log.Printf(fmt.Sprintf("About to listen on %s. Go to http://localhost:%s/", port, port))
	core.SetLogger()
	err := http.ListenAndServe(":"+port, nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}
